<template>
	<view style="background-color: #fff;">
		<tn-nav-bar :isBack="true" backgroundColor="#3A87FF" class="tatils">收货地址</tn-nav-bar>
		<view :style="{paddingTop: vuex_custom_bar_height + 'px'}">
			<view @click="got('/pages/address/add')" style="background-color: #3A87FF;color: #fff;
			border-radius: 5px;width: 80%;height: 40px;line-height: 40px;font-weight: 500;text-align: center;margin: 0 auto;margin-top: 10px;">新增收货地址</view>
			<view v-for="(item,index) in list" :key="index" style="width: 98%;margin: 0 auto;padding: 10px;display: block;overflow: hidden;margin-top: 5px;">
				<view style="overflow: hidden;width: 100%;box-shadow: 5px 5px 5px 5px rgba(225, 225, 225, 0.5);
				height: 100px;border-radius: 7px;">
					<view style="float: left;width: 85%;padding: 5px;height: 100px;">
						<view style="height: 30px;line-height: 30px;">{{item.real_name}}：{{item.phone}}</view>
						<view style="height: 52px;line-height: 26px;">{{item.region}}{{item.detail}}</view>
					</view>
					<view @click="got('/pages/address/edit?id='+item.id)" style="float: left;width: 15%;height: 100px;line-height: 100px;">
						<text style="font-size:24px" class="tn-icon-edit"></text>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		getaddress
	} from '@/apis/address.js'
	export default {

		data() {
			return {
				show:false,
				list:[]
			};
		},
		onShow() {
			this.getaddresss()
		},
		onLoad() {
			this.getaddresss()
		},
		methods:{
			getaddresss(){
				let data = {
					uid:uni.getStorageSync('uid')
				}
				getaddress(data).then(res => {
					console.log(res.data)
					this.list = res.data
				}).catch(error => {
					this.tool.toastTip('登录出错,请稍后重试!', 'none', 1000)
				})
			},
			got(e){
				uni.navigateTo({
					url:e
				})
			},
			addressConfirm(data){
				this.show = false
				console.log(data);
			}
		}
	}
</script>

<style lang="scss" scoped>
.tatils{
	color: #fff;
}
</style>
